package com.wzdigit.wms.basic.enums;

import java.util.*;

/**
 * 库位参数枚举类
 * @author yangdongjie
 * @LocationEnum.java
 * @2020年12月30日下午4:04:17
 */
public enum WarehouseEnum implements BaseEnum {
	
	/** 
	 * WhsType
	 * 仓库类型：
	 */
	RAW_MATERIALS_WHS(1, "原材料仓", "WhsType"), 
	NO_FINISHED_PRODUCT_WHS(2, "半成品仓", "WhsType"), 
	FINISHED_PRODUCT_WHS(3, "成品仓", "WhsType"),
	TRANSIT_WHS(4, "中转仓", "WhsType"),
	LINE_WHS(5, "线边仓", "WhsType"),
	BORROW_WHS(6, "借机仓", "WhsType");
	
	/**
	 * 枚举值
	 */
	public int code;

	/**
	 * 枚举名称
	 */
	public String enumName;

	/**
	 * 枚举实体类属性描述
	 */
	public String description;
	
	/**
	 * 可用库存的仓库类型
	 */
	public static List<Integer> availableInvWhsTypeList;
	public static List<Integer> availableInvWhsTypeListAuto;
	
	static {
		availableInvWhsTypeList = new ArrayList<>();
		availableInvWhsTypeList.add(RAW_MATERIALS_WHS.code);
		availableInvWhsTypeList.add(NO_FINISHED_PRODUCT_WHS.code);
		availableInvWhsTypeList.add(FINISHED_PRODUCT_WHS.code);
		availableInvWhsTypeList.add(TRANSIT_WHS.code);
		availableInvWhsTypeList.add(LINE_WHS.code);
		
		availableInvWhsTypeListAuto = new ArrayList<>();
		availableInvWhsTypeListAuto.add(RAW_MATERIALS_WHS.code);
		availableInvWhsTypeListAuto.add(NO_FINISHED_PRODUCT_WHS.code);
		availableInvWhsTypeListAuto.add(FINISHED_PRODUCT_WHS.code);
		availableInvWhsTypeListAuto.add(LINE_WHS.code);
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}
	
	public String getEnumName() {
		return enumName;
	}

	public void setEnumName(String enumName) {
		this.enumName = enumName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	WarehouseEnum(String enumName, String description) {
		this.enumName = enumName;
		this.description = description;
	}

	WarehouseEnum(int code, String enumName, String description) {
		this.code = code;
		this.enumName = enumName;
		this.description = description;
	}

	public static WarehouseEnum getEnumByCode(int enumCode) {
		WarehouseEnum[] values = WarehouseEnum.values();
		WarehouseEnum samplingEnum = null;

		for (WarehouseEnum value : values) {
			if (value.getCode() == enumCode) {
				samplingEnum = value;
			}
		}
		return samplingEnum;
	}

	public static WarehouseEnum getEnumByName(String enumName) {
		WarehouseEnum[] values = WarehouseEnum.values();
		WarehouseEnum repairEnum = null;

		for (WarehouseEnum value : values) {
			if (value.getEnumName() == enumName) {
				repairEnum = value;
			}
		}
		return repairEnum;
	}

	public static Map<Integer, String> getEnumByDescription(String enumDescription) {
		Map<Integer, String> enumMap = new HashMap<Integer, String>();
		WarehouseEnum[] values = WarehouseEnum.values();
		for (WarehouseEnum value : values) {
			if (Objects.equals(value.getDescription(), enumDescription)) {
				enumMap.put(value.getCode(), value.getEnumName());
			}
		}
		return enumMap;
	}
	
	public static List<Map<String, Object>> getEnumListByDescription(String enumDescription) {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		WarehouseEnum[] values = WarehouseEnum.values();
		for (WarehouseEnum value : values) {
			if (Objects.equals(value.getDescription(), enumDescription)) {
				Map<String, Object> enumMap = new HashMap<String, Object>(2);
				enumMap.put("code", value.getCode());
				enumMap.put("name", value.getEnumName());
				list.add(enumMap);
			}
		}
		return list;
	}
}
